/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import Model.Airplane;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;

/**
 *
 * @author Sony
 */
@ManagedBean(name="Airplanes")
@RequestScoped
public class AirplaneController {
    AirplaneHelper helper;
    private Airplane newAirplane;
    DataModel lstAirplane;
    public AirplaneController(){
        helper = new AirplaneHelper();
        newAirplane = new Airplane();
    }

    public DataModel listAirplane(){
        lstAirplane = new ListDataModel(this.helper.getAllAirplane());
        return lstAirplane;
    }
    
    public void addAirplane(){
        this.helper.updateAirplane(newAirplane);
    }
    
    public void editAirplane(Airplane a){
        this.helper.updateAirplane(a);
    }
    
    public void deleteAirplane(Airplane a){
        this.helper.deleteAirplane(a);
    }
    
    /**
     * @return the newAirplane
     */
    public Airplane getNewAirplane() {
        return newAirplane;
    }

    /**
     * @param newAirplane the newAirplane to set
     */
    public void setNewAirplane(Airplane newAirplane) {
        this.newAirplane = newAirplane;
    }
}
